package com.future.heatwave.db

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.future.heatwave.db.entity.AchieveDataBean
import com.future.heatwave.db.entity.FreeSectionsRecord
import com.future.heatwave.db.entity.GainMetadataBean
import com.future.heatwave.db.entity.ObtainRecordsBean
import com.future.heatwave.db.entity.ParticDatumBean
import com.future.heatwave.db.entity.SectionsEntityRecord


@Dao
interface  ItemDo{
    @Query("SELECT * FROM achieve")
    suspend fun getAllAchieve():List<AchieveDataBean>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertAchieve(achieveEntity: AchieveDataBean)

    @Delete()
    suspend fun deleteAchieve(achieveEntity: AchieveDataBean)

    @Query("SELECT * FROM gain")
    suspend fun getAllGain():List<GainMetadataBean>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertGain(gainMetadataBean: GainMetadataBean)

    @Delete()
    suspend fun deleteGain(gainMetadataBean: GainMetadataBean)

    @Query("SELECT * FROM obtain")
    suspend fun getAllObtain():List<ObtainRecordsBean>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertObtain(gainMetadataBean: ObtainRecordsBean)

    @Delete()
    suspend fun deleteObtain(gainMetadataBean: ObtainRecordsBean)

    @Query("SELECT * FROM partic_datum")
    suspend fun getAllPartic():List<ParticDatumBean>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertPartic(gainMetadataBean: ParticDatumBean)

    @Delete()
    suspend fun deletePartic(gainMetadataBean: ParticDatumBean)



    @Query("SELECT * FROM sections")
    suspend fun getAllSections():List<SectionsEntityRecord>


    @Query("select * from  sections where dramaId =:dramaId AND isOpen=:isOpen")
    suspend fun getDramaIdAllSections(dramaId:Long,isOpen:Boolean):List<SectionsEntityRecord>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertSections(gainMetadataBean: SectionsEntityRecord)

    @Delete()
    suspend fun deleteSections(gainMetadataBean: SectionsEntityRecord)

    @Query("SELECT * FROM sections_info")
    suspend fun getAllSectionsInfo():List<FreeSectionsRecord>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertSectionsInfo(gainMetadataBean: FreeSectionsRecord)

    @Delete()
    suspend fun deleteSectionsInfo(gainMetadataBean: FreeSectionsRecord)

}